home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Games / SoundSprocketTest / TS3Main.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  3.3 KB  |  164 lines  |  [TEXT/MPS ]

  1. /*
  2.  *    File:        TS3Main.c
  3.  *
  4.  *    Contents:    Main entry point, main loop, initialize and exit code
  5.  *
  6.  *    Copyright © 1996 Apple Computer, Inc.
  7.  */
  8.  
  9. #include <Dialogs.h>
  10. #include <Fonts.h>
  11. #include <Memory.h>
  12. #include <QuickDraw.h>
  13. #include <Types.h>
  14. #include <Windows.h>
  15.  
  16. #include <QD3D.h>
  17.  
  18. #include "TS3Events.h"
  19. #include "TS3Main.h"
  20. #include "TS3Menu.h"
  21. #include "TS3Message.h"
  22. #include "TS3Sound.h"
  23. #include "TS3TestAPI.h"
  24. #include "TS3TestHiLevel.h"
  25. #include "TS3TestLoLevel.h"
  26. #include "TS3Utils.h"
  27. #include "TS3Window.h"
  28.  
  29. #ifdef APP_LOADS_SOUND_COMPONENT
  30.     #include "S3Private.h"
  31. #endif
  32.  
  33. void main(
  34.     void);
  35.  
  36. static void Init(
  37.     void);
  38.  
  39. static void Exit(
  40.     void);
  41.  
  42.  
  43. static Boolean gAlive = false;
  44.  
  45.  
  46.  
  47. /* =============================================================================
  48.  *        main
  49.  *
  50.  *    Initializes, processes events, does the idle-time stuff, and exits.
  51.  * ========================================================================== */
  52. void main(
  53.     void)
  54. {
  55.     Init();
  56.     
  57.     while (gAlive)
  58.     {
  59.         Events_Process();
  60.     }
  61.     
  62.     Exit();
  63. }
  64.  
  65.  
  66. /* =============================================================================
  67.  *        Main_LastRoundup (external)
  68.  *
  69.  *    Requests the main event loop to gracefully exit.
  70.  * ========================================================================== */
  71. void Main_LastRoundup(
  72.     void)
  73. {
  74.     gAlive = false;
  75. }
  76.  
  77.  
  78. /* =============================================================================
  79.  *        Init (internal)
  80.  *
  81.  *    Initialization of toolbox and our stuff.
  82.  * ========================================================================== */
  83. void Init(
  84.     void)
  85. {
  86.     // Initialize the toolbox
  87.      MaxApplZone();
  88.     MoreMasters();
  89.     
  90.     InitGraf(&qd.thePort);
  91.     InitFonts();
  92.     InitWindows();
  93.     InitDialogs(NULL);
  94.     InitCursor();
  95.     InitMenus();
  96.     TEInit();
  97.     
  98.     // Should we load S3Localization?
  99.     #ifdef APP_LOADS_SOUND_COMPONENT
  100.     {
  101.         ComponentDescription    filterDesc;
  102.         Handle                    filterNameHdl;
  103.         Handle                    infoHdl;
  104.         
  105.         // Register (or find) our components
  106. #ifdef REAL_3D_INSTALL
  107.         filterDesc.componentType            = kSoundEffectsType;
  108. #else
  109.         filterDesc.componentType            = 'sdec';
  110. #endif
  111.         filterDesc.componentSubType            = kSSpLocalizationSubType;
  112.         filterDesc.componentManufacturer    = kAppleManufacturer;
  113.         filterDesc.componentFlags            = 0L;
  114.         filterDesc.componentFlagsMask        = 0L;
  115.         
  116.         filterNameHdl = NewHandle (sizeof (Str255));
  117.         BlockMove ((Ptr)"\pS3Localization", (Ptr)(*filterNameHdl), sizeof (Str255));
  118.  
  119.         infoHdl = NewHandle (sizeof (Str255));
  120.         BlockMove ((Ptr)"\pThis component provides 3D Audio.", (Ptr)(*infoHdl), sizeof (Str255));
  121.         
  122.         // Register the Filter component
  123.         RegisterComponent (&filterDesc, NewComponentRoutineProc(SoundComponentProc), kRegisterGlobally,
  124.             filterNameHdl, infoHdl, nil);
  125.     }
  126.     #endif
  127.     
  128.     // Initialize our modules
  129.     Utils_Init();
  130.     Message_Init();
  131.     Menu_Init();
  132.     Events_Init();
  133.     Window_Init();
  134.     TestHiLevel_Init();
  135.     Sound_Init();
  136.     TestLoLevel_Init();
  137.     TestAPI_Init();
  138.     
  139.     // We're off...
  140.     gAlive = true;
  141. }
  142.  
  143.  
  144. /* =============================================================================
  145.  *        Exit (internal)
  146.  *
  147.  *    Cleans up before exit.
  148.  * ========================================================================== */
  149. void Exit(
  150.     void)
  151. {
  152.     // Exit our modules
  153.     TestLoLevel_Exit();
  154.     TestHiLevel_Exit();
  155.     TestAPI_Exit();
  156.     Sound_Exit();
  157.     Window_Exit();
  158.     Events_Exit();
  159.     Menu_Exit();
  160.     Message_Exit();
  161.     Utils_Exit();
  162. }
  163.  
  164.